#include "WidgetVariantUrl.h"
#include "ui_WidgetVariantUrl.h"
#include <QtCore/QVariant>
#include <QtWidgets/QFileDialog>

WidgetVariantUrl::WidgetVariantUrl(QWidget *parent) :
    WidgetVariant(parent),
    ui(new Ui::WidgetVariantUrl)
{
    ui->setupUi(this);
    QObject::connect(ui->pushButton, SIGNAL(clicked(bool)),
                     this, SLOT(slotButtonClicked(bool)));
    m_fileType = "*";
}

WidgetVariantUrl::~WidgetVariantUrl()
{
    delete ui;
}

void WidgetVariantUrl::refreshByProperty(EItemMetaPropertyPtr p)
{
    /*
    WidgetVariant::refreshByProperty(property );
    ui->labelName->setText( property.nameCN.isEmpty() ? property.name : property.nameCN);
    QUrl u = property.value.toUrl();
    m_fileType = u.scheme();
    if(m_fileType.isEmpty())
    {
        m_fileType = "*";
    }
    
    ui->lineEdit->setText(u.path());
    */

}

void WidgetVariantUrl::slotButtonClicked(bool boolValue)
{
    /*
    QString config = QString("Config Files") + "(*." + m_fileType + ")";
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), "", config);
    ui->lineEdit->setText(fileName);

    QUrl u;
    u.setPath(fileName);
    u.setScheme(m_fileType);
    QVariant v(u);
    emit signalVariantChanged(WidgetVariant::getModuleName(),  WidgetVariant::getProperty().name, v);
    */
}
